<div ng-cloak>

  <div uib-navbar profile="profile"></div>

  <div class="framework-main">
    <div uib-sidebar profile="profile" class="sidebar-full" is-collapse="userview.isCollapse" groups="userview.sidebarGroups" item-selected="userview.sidebarSelected"></div>

    <div class="framework-body">
      <uib-breadcrumb class="breadcrumb-wrapper" breads="userview.breads"></uib-breadcrumb>

      <div ng-if="type === 'create' && !loading">
        <div class="tools">
          <div class="btn-group" role="group" aria-label="">
            <a href="{{redirect_url}}" class="btn btn-default btn-info" uib-tooltip="返回" tooltip-append-to-body="true" tooltip-placement="top" ><i class="fa fa-fw fa-chevron-left"></i><span class="hidden-xs"> 返回</span></a>
          </div>
        </div>

        <div class="row mt-10">
          <div class="col-md-12">
            <div class="panel panel-default panel-csc">
              <div class="panel-heading">
                <div class="panel-title">新增用户</div>
              </div>
              <div class="panel-body">
                <form name="form" class="form form-horizontal" ng-submit="createSubmit(form.$valid)" novalidate>
                  <!--<div class="form-group">-->
                    <!--<label class="col-sm-2 control-label"><span class="span-danger">*</span>用户姓名:</label>-->
                    <!--<div class="col-sm-10">-->
                      <!--<input type="text" ng-model="info.name" name="name" class="form-control" placeholder="用户姓名" required>-->
                      <!--<div class="error-messages" ng-messages="form.name.$error">-->
                        <!--<small class="error" ng-message="required">用户姓名（*必填）</small>-->
                      <!--</div>-->
                    <!--</div>-->
                  <!--</div>-->
                  <!--<div class="form-group">-->
                    <!--<label class="col-sm-2 control-label"><span class="span-danger">*</span>登录密码:</label>-->
                    <!--<div class="col-sm-10">-->
                      <!--<input type="password" ng-model="info.password" name="password" class="form-control" placeholder="登录密码" minlength="6" maxlength="10" ng-minlength="6" ng-maxlength="10" required ng-pattern="/(?=.*[a-zA-Z])(?=.*[^a-zA-Z])/">-->
                      <!--<div class="error-messages" ng-messages="form.password.$error">-->
                        <!--<small class="error" ng-message="required">登录密码必须为6-10个字符（*数字或英文字符）</small>-->
                        <!--<small class="error" ng-message="minlength">登录密码必须为6-10个字符（*数字或英文字符）</small>-->
                        <!--<small class="error" ng-message="maxlength">登录密码必须为6-10个字符（*数字或英文字符）</small>-->
                        <!--<small class="error" ng-message="pattern">登录密码必须包含数字和英文字符</small>-->
                      <!--</div>-->
                    <!--</div>-->
                  <!--</div>-->

                  <!--<div class="form-group">-->
                    <!--<label class="col-sm-2 control-label"><span class="span-danger">*</span>确认登录密码:</label>-->
                    <!--<div class="col-sm-10">-->
                      <!--<input type="password" ng-model="info.confirm" name="confirm" class="form-control" placeholder="确认登录密码" required equal-to="info.password">-->
                      <!--<div class="error-messages" ng-messages="form.confirm.$error">-->
                        <!--<small class="error" ng-message="required">请确认登录密码（*必填）</small>-->
                        <!--<small class="error" ng-message="notEqual">两次输入的登录密码不一致</small>-->
                      <!--</div>-->
                    <!--</div>-->
                  <!--</div>-->

                  <!--<div class="form-group">-->
                    <!--<label class="col-sm-2 control-label">钉钉账号:</label>-->
                    <!--<div class="col-sm-10">-->
                      <!--<input type="text" ng-model="info.ding_id" class="form-control" placeholder="钉钉账号">-->
                    <!--</div>-->
                  <!--</div>-->
                  <!--<div class="form-group form-select-group">-->
                    <!--<label class="col-sm-2 control-label"><span class="span-danger">*</span>手机号:</label>-->
                    <!--<div class="col-sm-10">-->
                      <!--<input type="text" ng-model="info.cellphone" name="cellphone" class="form-control" placeholder="手机号" required maxlength="11" minlength="11" ng-pattern="/^1\d{10}$/">-->
                      <!--<div class="error-messages" ng-messages="form.cellphone.$error">-->
                        <!--<small class="error" ng-message="required">手机号（*必填）</small>-->
                        <!--<small class="error" ng-message="minlength">请输入11位手机号</small>-->
                        <!--<small class="error" ng-message="maxlength">请输入11位手机号</small>-->
                        <!--<small class="error" ng-message="pattern">请输入正确格式的手机号</small>-->
                      <!--</div>-->
                    <!--</div>-->
                  <!--</div>-->
                  <div class="form-group form-select-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>手机号:</label>
                    <div class="col-sm-10">
                      <div class="input-group input-group-warning">
                        <input ng-keypress="keyPress($event)" ng-keyup="keyUp($event)" type="text" ng-model="info.cellphone" name="cellphone" class="form-control" placeholder="手机号" required maxlength="11" minlength="11" ng-pattern="/^1\d{10}$/">
                        <span class="input-group-addon input-group-addon-btn"><button id="mobilephoneCheck" type="button" ng-click="mobilephoneExists($event)" class="btn btn-warning">手机号验证</button></span>
                      </div>
                      <div class="error-messages" ng-messages="form.cellphone.$error">
                        <small class="error" ng-message="required">手机号（*必填）</small>
                        <small class="error" ng-message="minlength">请输入11位手机号</small>
                        <small class="error" ng-message="maxlength">请输入11位手机号</small>
                        <small class="error" ng-message="pattern">请输入正确格式的手机号</small>
                      </div>
                      <!--<input type="hidden" ng-model="validator.role_string" name="role_string" class="form-control" placeholder="用户角色" required></input>
                      <div class="error-messages" ng-messages="form.role_string.$error">
                        <small class="error" ng-message="required">验证手机号（*必填）</small>
                      </div>-->
                    </div>
                  </div>
                  <!--<div class="form-group">-->
                    <!--<label class="col-sm-2 control-label"><span class="span-danger">*</span>用户角色:</label>-->
                    <!--<div class="col-sm-10">-->
                      <!--<div class="form-control-select">-->
                        <!--<select name="roleselect" class="input-select input-select-w100" placeholder="用户角色"></select>-->
                      <!--</div>-->
                      <!--<input type="hidden" ng-model="validator.role_string" name="role_string" class="form-control" placeholder="用户角色" required></input>-->
                      <!--<div class="error-messages" ng-messages="form.role_string.$error">-->
                        <!--<small class="error" ng-message="required">用户角色（*必填）</small>-->
                      <!--</div>-->
                    <!--</div>-->
                  <!--</div>-->

                  <div class="form-group" ng-if="flagMobile">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>用户角色:</label>
                    <div class="col-sm-10">
                      <div class="form-control-select">
                        <select name="roleselect" class="input-select input-select-role input-select-w100" placeholder="用户角色"></select>
                      </div>
                      <input type="hidden" ng-model="validator.role_string" name="role_string" class="form-control" placeholder="用户角色" required></input>
                      <div class="error-messages" ng-messages="form.role_string.$error">
                        <small class="error" ng-message="required">用户角色（*必填）</small>
                      </div>
                    </div>
                  </div>

                  <div class="form-group" ng-if="hasRoleId(info.selectRoles,'4') && flagMobile">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>网吧名称:</label>
                    <div class="col-sm-10">
                      <div class="form-control-select">
                        <select name="nameselect" class="input-select input-select-name input-select-w100" placeholder="网吧名称"></select>
                      </div>
                      <input type="hidden" ng-model="validator.deploy_barname" name="deploy_barname" class="form-control" placeholder="网吧名称" required></input>
                      <div class="error-messages" ng-messages="form.deploy_barname.$error">
                        <small class="error" ng-message="required">网吧名称（*必填）</small>
                      </div>
                    </div>
                  </div>

                  <div class="form-group" ng-if="hasRoleId(info.selectRoles,'9') && flagMobile">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>渠道邀请码:</label>
                    <div class="col-sm-10">
                      <input type="text" ng-model="info.code" name="code" class="form-control" placeholder="渠道邀请码" required></input>
                      <div class="error-messages" ng-messages="form.code.$error">
                      <small class="error" ng-message="required">渠道邀请码（*必填）</small>
                      </div>
                    </div>
                  </div>

                  <div class="form-group" ng-if="flagMobile">
                    <div class="col-sm-offset-2 col-sm-10">
                      <div class="btn-group" role="group" aria-label="">
                        <button class="btn btn-default btn-success" ng-disabled="form.$invalid"><i class="fa fa-fw fa-save"></i> 保存</button>
                      </div>
                      <div class="btn-group" role="group" aria-label="">
                        <a href="{{redirect_url}}" class="btn btn-default btn-danger"><i class="fa fa-fw fa-mail-forward"></i> 放弃</a>
                      </div>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div ng-if="type === 'view' && !loading">
        <div class="tools">
          <div class="btn-group" role="group" aria-label="">
            <a href="{{redirect_url}}" class="btn btn-default btn-info" uib-tooltip="返回" tooltip-append-to-body="true" tooltip-placement="top" ><i class="fa fa-fw fa-chevron-left"></i><span class="hidden-xs"> 返回</span></a>
          </div>
          <div ng-if="cfg.hasAuth(profile, cfg.api.user.update.url) && info.ticket_status !== 3 && (cfg.hasRoleId(profile.roles,'1') || cfg.hasRoleId(profile.roles,'8') || (cfg.hasRoleId(profile.roles,'9') && info.status !== 1) || (cfg.hasRoleId(profile.roles,'10') && info.status !== 1))"  class="btn-group" role="group" aria-label="">
            <a ng-click="goview('userview', 'edit', id)" class="btn btn-default btn-warning" uib-tooltip="编辑" tooltip-append-to-body="true" tooltip-placement="top" ><i class="fa fa-fw fa-edit"></i><span class="hidden-xs"> 编辑</span></a>
          </div>
         <!-- <div ng-if="cfg.hasAuth(profile, cfg.api.user.reset.url)" class="btn-group" role="group" aria-label="">
            <a ng-click="goview('userview', 'reset', id)" class="btn btn-default btn-success" uib-tooltip="重置密码" tooltip-append-to-body="true" tooltip-placement="top" ><i class="fa fa-fw fa-edit"></i><span class="hidden-xs"> 重置密码</span></a>
          </div>-->
          <div ng-if="cfg.hasAuth(profile, cfg.api.role.delete.url) && info.ticket_status !== 3 && (cfg.hasRoleId(profile.roles,'1') || cfg.hasRoleId(profile.roles,'8') || (cfg.hasRoleId(profile.roles,'9') && info.status !== 1) || (cfg.hasRoleId(profile.roles,'10') && info.status !== 1))"  class="btn-group" role="group" aria-label="">
            <a ng-click="deleteSubmit(id)" class="btn btn-default btn-danger" uib-tooltip="删除" tooltip-append-to-body="true" tooltip-placement="top" ><i class="fa fa-fw fa-trash"></i><span class="hidden-xs"> 删除</span></a>
          </div>
        </div>

        <div class="row mt-10">
          <div class="col-md-12">
            <div class="panel panel-default panel-csc">
              <div class="panel-heading">
                <div class="panel-title">查看用户</div>
              </div>
              <div class="panel-body">
                <div class="form form-horizontal">
                  <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>用户姓名:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.name}}</p>
                    </div>
                  </div>
                  <div class="form-group form-select-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>钉钉账号:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.ding_id}}</p>
                    </div>
                  </div>
                  <div class="form-group form-select-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>手机号:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.cellphone}}</p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>用户角色:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{getRoleToArray(info.role, 'name').join(",")}}</p>
                    </div>
                  </div>
                  <div class="form-group" ng-if="hasRoleId(info.selectRoles,'4') && info.bossWangbas">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>网吧名称:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.bossWangbas ? info.bossWangbas.name: ''}}</p>
                    </div>
                  </div>

                  <!--<div class="form-group" ng-if="hasRoleId(info.roles,'9') && flagMobile">-->
                    <!--<label class="col-sm-2 control-label"><span class="span-danger">*</span>渠道邀请码:</label>-->
                    <!--<div class="col-sm-10">-->
                      <!--<p class="form-control-static">{{info.code}}</p>-->
                    <!--</div>-->
                  <!--</div>-->

                  <div class="form-group form-select-group" ng-if="hasRoleId(info.selectRoles,'9') && info.code">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>渠道邀请码:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.code}}</p>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div ng-if="type === 'edit' && !loading">
        <div class="tools">
          <div class="btn-group" role="group" aria-label="">
            <a href="{{redirect_url}}" class="btn btn-default btn-info" uib-tooltip="返回" tooltip-append-to-body="true" tooltip-placement="top" ><i class="fa fa-fw fa-chevron-left"></i><span class="hidden-xs"> 返回</span></a>
          </div>
        </div>

        <div class="row mt-10">
          <div class="col-md-12">
            <div class="panel panel-default panel-csc">
              <div class="panel-heading">
                <div class="panel-title">编辑用户</div>
              </div>
              <div class="panel-body">
                <form name="form" class="form form-horizontal" ng-submit="editSubmit(id, form.$valid)" novalidate>
                  <!--<div class="form-group">-->
                    <!--<label class="col-sm-2 control-label"><span class="span-danger">*</span>用户姓名:</label>-->
                    <!--<div class="col-sm-10">-->
                      <!--<input type="text" ng-model="info.name" name="name" class="form-control" placeholder="用户姓名" required>-->
                      <!--<div class="error-messages" ng-messages="form.name.$error">-->
                        <!--<small class="error" ng-message="required">用户姓名（*必填）</small>-->
                      <!--</div>-->
                    <!--</div>-->
                  <!--</div>-->

                  <!--<div class="form-group">-->
                    <!--<label class="col-sm-2 control-label"><span class="span-danger">*</span>钉钉账号:</label>-->
                    <!--<div class="col-sm-10">-->
                      <!--<input type="text" ng-model="info.ding_id" class="form-control" placeholder="钉钉账号">-->
                    <!--</div>-->
                  <!--</div>-->

                  <div class="form-group form-select-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>手机号:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.cellphone}}</p>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>用户角色:</label>
                    <div class="col-sm-10">
                      <div class="form-control-select">
                        <select name="roleselect" class="input-select input-select-role input-select-w100" placeholder="用户角色"></select>
                      </div>
                      <input type="hidden" ng-model="validator.role_string" name="role_string" class="form-control" placeholder="用户角色" required></input>
                      <div class="error-messages" ng-messages="form.role_string.$error">
                        <small class="error" ng-message="required">用户角色（*必填）</small>
                      </div>
                    </div>
                  </div>

                  <div class="form-group" ng-if="info.selectRoles && hasRoleId(info.selectRoles,'4')">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>网吧名称:</label>
                    <div class="col-sm-10">
                      <div class="form-control-select">
                        <select name="nameselect" class="input-select input-select-name input-select-w100" placeholder="网吧名称"></select>
                      </div>
                      <input type="hidden" ng-model="validator.deploy_barname" name="deploy_barname" class="form-control" placeholder="网吧名称" required></input>
                      <div class="error-messages" ng-messages="form.deploy_barname.$error">
                        <small class="error" ng-message="required">网吧名称（*必填）</small>
                      </div>
                    </div>
                  </div>

                  <div class="form-group form-select-group" ng-if="info.selectRoles && hasRoleId(info.selectRoles,'9') && info.code">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>渠道邀请码:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.code}}</p>
                    </div>
                  </div>

                  <div class="form-group" >
                    <div class="col-sm-offset-2 col-sm-10">
                      <div class="btn-group" role="group" aria-label="">
                        <button class="btn btn-default btn-success" ng-disabled="form.$invalid"><i class="fa fa-fw fa-save"></i> 保存</button>
                      </div>
                      <div class="btn-group" role="group" aria-label="">
                        <a href="{{redirect_url}}" class="btn btn-default btn-danger"><i class="fa fa-fw fa-mail-forward"></i> 放弃</a>
                      </div>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div ng-if="type === 'reset' && !loading">
        <div class="tools">
          <div class="btn-group" role="group" aria-label="">
            <a href="{{redirect_url}}" class="btn btn-default btn-info" uib-tooltip="返回" tooltip-append-to-body="true" tooltip-placement="top" ><i class="fa fa-fw fa-chevron-left"></i><span class="hidden-xs"> 返回</span></a>
          </div>
        </div>

        <div class="row mt-10">
          <div class="col-md-12">
            <div class="panel panel-default panel-csc">
              <div class="panel-heading">
                <div class="panel-title">重置密码</div>
              </div>
              <div class="panel-body">
                <form name="form" class="form form-horizontal" ng-submit="resetPasswordSubmit(id, form.$valid)" novalidate>
                  <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>用户姓名:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.name}}</p>
                    </div>
                  </div>
                  <div class="form-group form-select-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>钉钉账号:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.ding_id || '未填写'}}</p>
                    </div>
                  </div>
                  <div class="form-group form-select-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>手机号:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{info.cellphone || '未填写'}}</p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>用户角色:</label>
                    <div class="col-sm-10">
                      <p class="form-control-static">{{getRoleToArray(info.role, 'name').join(",")}}</p>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>登录密码:</label>
                    <div class="col-sm-10">
                      <input type="password" ng-model="info.newPassword" name="newPassword" class="form-control" placeholder="登录密码" minlength="6" maxlength="10" ng-minlength="6" ng-maxlength="10" required ng-pattern="/(?=.*[a-zA-Z])(?=.*[^a-zA-Z])/">
                      <div class="error-messages" ng-messages="form.newPassword.$error">
                        <small class="error" ng-message="required">登录密码必须为6-10个字符（*数字或英文字符）</small>
                        <small class="error" ng-message="minlength">登录密码必须为6-10个字符（*数字或英文字符）</small>
                        <small class="error" ng-message="maxlength">登录密码必须为6-10个字符（*数字或英文字符）</small>
                        <small class="error" ng-message="pattern">登录密码必须包含数字和英文字符</small>
                      </div>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>确认登录密码:</label>
                    <div class="col-sm-10">
                      <input type="password" ng-model="info.confirm" name="confirm" class="form-control" placeholder="确认登录密码" required equal-to="info.newPassword">
                      <div class="error-messages" ng-messages="form.confirm.$error">
                        <small class="error" ng-message="required">请确认登录密码（*必填）</small>
                        <small class="error" ng-message="notEqual">两次输入的登录密码不一致</small>
                      </div>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="span-danger">*</span>操作人员密码:</label>
                    <div class="col-sm-10">
                      <input type="password" ng-model="info.password" name="password" class="form-control" placeholder="操作人员密码" minlength="6" maxlength="10" ng-minlength="6" ng-maxlength="10" required ng-pattern="/(?=.*[a-zA-Z])(?=.*[^a-zA-Z])/">
                      <div class="error-messages" ng-messages="form.password.$error">
                        <small class="error" ng-message="required">操作人员密码必须为6-10个字符（*数字或英文字符）</small>
                        <small class="error" ng-message="minlength">操作人员密码必须为6-10个字符（*数字或英文字符）</small>
                        <small class="error" ng-message="maxlength">操作人员密码必须为6-10个字符（*数字或英文字符）</small>
                        <small class="error" ng-message="pattern">操作人员密码必须包含数字和英文字符</small>
                      </div>
                    </div>
                  </div>

                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <div class="btn-group" role="group" aria-label="">
                        <button class="btn btn-default btn-success" ng-disabled="form.$invalid"><i class="fa fa-fw fa-save"></i> 确定重置</button>
                      </div>
                      <div class="btn-group" role="group" aria-label="">
                        <a href="{{redirect_url}}" class="btn btn-default btn-danger"><i class="fa fa-fw fa-mail-forward"></i> 放弃重置</a>
                      </div>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>

</div>
